<template>
  <view style="padding-top: 100rpx;">
    <!-- 输入值区域 -->
    <view class="text-area">
      <text>输入值:</text>
      <input 
        type="text" 
        v-model="title" 
        style="color: red; border: 1px solid #ddd; padding: 15rpx; margin-left: 10rpx; border-radius: 8rpx; flex: 1;" 
        placeholder="请输入要传递给子组件A的值"
      />
    </view>
    <!-- 回传值区域 -->
    <view class="text-area" style="margin-top: 20rpx;">
      <text>回传值:</text>
      <input 
        type="text" 
        :value="callBackValue" 
        style="color: blue; border: 1px solid #ddd; padding: 15rpx; margin-left: 10rpx; border-radius: 8rpx; background: #fff; flex: 1;" 
        disabled
      />
    </view>

    <!-- 子组件A -->
    <comA :intent="title" style="margin-top: 40rpx;"></comA>
    
    <!-- 子组件B -->
    <comB @callBackFun="handleCallBack" style="margin-top: 30rpx;"></comB>
  </view>
</template>

<script>

import comA from '../../components/ComA.vue'
import comB from '../../components/ComB.vue'

export default {
  components: { comA, comB },
  data() {
    return {
      title: '', 
      callBackValue: '' 
    }
  },
  methods: {
    handleCallBack(msg) {
      console.warn("---父组件---接收子组件B回传值-->", msg);
      this.callBackValue = msg; 
    }
  }
}
</script>

<style scoped>
.text-area {
  display: flex;
  align-items: center;
  margin: 0 20rpx;
  font-size: 28rpx;
}
</style>